package cn.com.bluemoon.daps.notice.infrastructure.entity;

import cn.com.bluemoon.daps.common.domain.BaseModel;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 邮件发送记录表
 * </p>
 *
 * @author admin
 * @since 2021-06-15
 */
@Data
@Accessors
@ApiModel(value = "DapSendMailRecord", description = "邮件发送记录表")
public class DapSendMailRecord extends BaseModel<DapSendMailRecord> {

    public static final String COMMA = StrUtil.COMMA;
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "收件人")
    private String addressee;
    @ApiModelProperty(value = "发件人")
    private String sender;
    @ApiModelProperty(value = "邮件主题")
    private String mailTheme;
    @ApiModelProperty(value = "发件原因")
    private String sendReason;
    @ApiModelProperty(value = "发件说明")
    private String reasonDescription;
    @ApiModelProperty(value = "发件内容")
    private String sendContent;
    /**
     * 后续需要增加状态为失败的进行重发
     */
    @ApiModelProperty(value = "发送情况")
    private Boolean sendStatus;

    /**
     * 获取收件人列表
     *
     * @return list
     */
    public List<String> getAddressees() {
        return getAddressee() != null ? Arrays.asList(getAddressee().split(COMMA)) : null;
    }

    /**
     * 写入收件人立碑信息
     *
     * @param rec
     */
    public void setAddressees(List<String> rec) {
        setAddressee(String.join(COMMA, rec));
    }
}
